/**
 * 
 * String 扩展
 */

plugor.len = function(str){
	return str?str.replace(/[^\x00-\xff]/g,"xx").length:0;
};
/*@Annotations
	{parent:'工具篇',name:'startsWith(str,prefix,bool)',title:'',
		describe:'判断字符串是否以XX开头\n
			调用方法:plugor.startsWith(str, prefix,bool);
			@return boolean
			@param
				str:被判断字符串;
				prefix:判断开头字符串;
				bool:是否区分大小写,为true则不区分大小写,false则区分大小写;
			@eg
				var str = "abcdef";
				plugor.startsWith(str,'ab');//return true;
				plugor.startsWith(str,'aB');//return false;
				plugor.startsWith(str,'aB',true);//return true;
		'
	}
*/
plugor.startsWith = function(str, prefix,bool){
	if(bool){
		str = str.toLowerCase();
		prefix = prefix.toLowerCase();	
	}
	return str.indexOf(prefix) == 0;
};
/*@Annotations
	{parent:'工具篇',name:'endsWith(str,prefix,bool)',title:'',
		describe:'判断字符串是否以XX结尾\n
			调用方法:plugor.endsWith(str, prefix,bool);
			@return boolean
			@param
				str:被判断字符串;
				suffix:判断结尾字符串;
				bool:是否区分大小写,为true则不区分大小写,false则区分大小写;
			@eg
				请参照plugor.startsWith(str, prefix,bool);
		'
	}
*/
plugor.endsWith = function(str, suffix,bool){
	if(bool){
		str = str.toLowerCase();
		prefix = prefix.toLowerCase();	
	}
	return str.lastIndexOf(suffix) == (str.length - suffix.length);
};
/*@Annotations
	{parent:'工具篇',name:'trim(str,prefix,bool)',title:'',
		describe:'去除字符串两端空格\n
			调用方法:plugor.trim(str);
			@return str;
			@param
				str:字符串;
		'
	}
*/
plugor.trim = function( text ) {
	return (text || "").replace( /^\s+|\s+$/g, "" );
};